<%@ tag language="java" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ attribute name="groups" type="java.lang.String" required="true" 
	description="通过任务ID获得cadicadeGroup:如果是多个cadicade使用‘,’分开"%>
<link href="${ctxStatic}/jquery-ui/1.10.3/jquery-ui-1.10.3.css" type="text/css" rel="stylesheet" />
<fieldset>
	<legend>指派处理人</legend>
	
	<label class="control-label">选择相关组:</label>
	<select onchange="selectRolesOption(this)" class="required" name="varMap.candicadeGroup" id="act_group">
		<option value="">----请选择----</option>
		<c:forEach items="${fns:findByRoleEnmames(groups)}" var="role">
			<option value="${role.enName}">${role.name}</option>
		</c:forEach>
	</select>
	选择办理人员
	<input id="act_users" name="varMap.inititor" class="required" type="text">
</fieldset>
<script>
 	var userInfo;
 	function user(loginName,name) //声明对象
    {
 	   this.value=loginName;
       this.label=loginName;
       this.loginName = loginName;
       this.name= name;
    }
	function selectRolesOption(me){
		$("#act_users").val("");
		var $sel_option=$(me).val();
		if($sel_option==''){
			call();
			return;
		}
		$.get("${ctx}/act/tags/findUsersByRole?role="+$sel_option, function(data){
			userInfo=new Array();
			$.each(data, function(k, v){
				userInfo.push(new user(v.loginName,v.name));
			});call();
		});
	}
	function call(){
		$("#act_users").autocomplete({
	    	minLength: 1,
	      	source: userInfo,
      		focus: function( event, ui ) {
      			$("#act_users").val(ui.item.loginName);
             	return false;},
            select: function( event, ui ){
            	$("#act_users").val( ui.item.loginName);
            	return false;
            }
	    }).data( "ui-autocomplete" )._renderItem = function( ul, item ) {
	        return $( "<li>" )
	        .append( "<a>[" + item.name + "]" + item.loginName + "</a>" )
	        .appendTo(ul);
	    };
	}
 </script>
